package com.gitee.jmliu1983.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import com.alibaba.fastjson2.JSONArray;


@Mapper
public interface MySqlDaoMapper {
	@Update("<script>"
			+ "UPDATE `${table}` SET  `${jsonFieldName}`= JSON_SET(`${jsonFieldName}`,"
			+ "<foreach collection='objMap' open='' separator=',' close='' index='k' item='v' >"
			+ "'$.${k}',#{v}"
			+ "</foreach>"
			+ ") WHERE `id` IN "
			+ "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'>"
			+ "#{item}"
			+ "</foreach>"
			+ "</script>")
	void updateJson(@Param("table") String table, @Param("jsonFieldName") String jsonFieldName,  @Param("idList") JSONArray idList, @Param("objMap") Map<String, Object> objMap);

}
